home *** CD-ROM | disk | FTP | other *** search
- (*
- * PRNSYM, copyright (C) 1986 by Dan Griffith, is released into
- * the public domain for non-commercial use only.
- *
- * PRNSYM converts a .PRN file created by the Z80MR assembler (and
- * possibly others) and creates a .SYM (symbol table) file that
- * can be used by the Z8E monitor/debugger (and possibly others).
- *
- * Proper invocation syntax is:
- *
- * PRNSYM [prnfile [symfile]]
- *
- * where prnfile is the [optional] .PRN file,
- * and symfile is the [optional] .SYM file.
- * If no filename suffixes are given, .PRN and .SYM are assumed.
- * If no filenames are entered on the command line, the user will
- * be prompted for the .PRN filename.
- *
- *)
-
- Var
- f1,f2: Text;
- inpstr: String[80];
- filename: String[14];
- count: Integer;
-
- Begin
-
- WriteLn('PRNSYM v1.1');
- WriteLn('(C) 1986 by Dan Griffith');
- Write('Name of .PRN file to convert: ');
-
- If (ParamCount<1) Then
- ReadLn(filename) (* get file name from user *)
- Else Begin
- WriteLn(ParamStr(1));
- filename:=ParamStr(1); (* get file name from command line *)
- End;
-
- If Pos('.',filename)=0 Then (* if no suffix, *)
- Assign(f1,filename+'.PRN') (* assume .PRN *)
- Else
- Assign(f1,filename); (* otherwise, leave explicit *)
-
- If (ParamCount<2) Then (* if no output file named *)
- If (Pos('.',filename)=0) Then (* if no suffix, *)
- Assign(f2,filename+'.SYM') (* assume .SYM *)
- Else
- Assign(f2,Copy(filename,1,Pred(Pos('.',filename)))+'.SYM')
- Else (* if output file named *)
- If (Pos('.',ParamStr(2))=0) Then (* if no suffix, *)
- Assign(f2,ParamStr(2)+'.SYM') (* assume .SYM *)
- Else
- Assign(f2,ParamStr(2)); (* otherwise, leave explicit *)
-
- {$i-} Reset(f1); {$i+}
- If (IOResult=0) Then Begin (* make sure file was opened *)
-
- {$i-} ReWrite(f2); {$i+}
- If (IOResult<>0) Then Begin (* make sure file was created *)
- WriteLn('Disk or directory full. PRNSYM aborted.');
- Close(f1);
- Close(f2);
- Erase(f2);
- HALT;
- End;
-
- inpstr:='';
-
- (* search for ASEG SYMBOLS *)
- While (Not ((Eof(f1) Or (inpstr='ASEG SYMBOLS')))) Do
- ReadLn(f1,inpstr);
-
- If (inpstr<>'ASEG SYMBOLS') Then Begin
- WriteLn('Symbols not found in .PRN file. PRNSYM aborted.');
- Close(f1);
- Close(f2);
- Erase(f2);
- HALT;
- End;
-
- ReadLn(f1,inpstr);
-
- count:=0; (* count # of symbols *)
- ReadLn(f1,inpstr); (* get a line of input *)
- Repeat
- While (inpstr<>'') Do
- (* reverse order and output *)
- While Pos(' ',inpstr)>0 Do Begin
- {$i-} WriteLn(f2,Copy(inpstr,8,5),Copy(inpstr,1,7)); {$i+}
- If (IOResult<>0) Then Begin
- WriteLn('Disk Full. PRNSYM aborted.');
- WriteLn(count,' symbols converted.');
- Close(f2);
- Close(f1);
- HALT;
- End;
- inpstr:=Copy(inpstr,13,255);
- count:=Succ(count);
- End;
- ReadLn(f1,inpstr); (* get more input *)
- Until (inpstr='') Or (Eof(f1));
-
- Close(f2);
- Close(f1);
-
- WriteLn(count,' symbols.');
-
- End Else Begin
- WriteLn('.PRN file not found. PRNSYM aborted.');
- WriteLn('PRNSYM syntax is: PRNSYM [prnfile [symfile]]');
- Close(f1);
- End;
-
- End.
- found. PRNSYM aborted.');
-